<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 CalenderUI();
 link_js(array('jquery.fixedheader','bootstrap-typeahead'),'asset/js/');
 ?>
<!--<div class='container'>-->
     <div class="tabbable"> <!-- Only required for left/right tabs -->
	<?=$tab_header;?>
       <div class="tab-content" style=''>
	   <br>
            <div class="tab-pane" id="table1"></div>
            <div class="tab-pane active" id="table2"><?=$this->zetro_auth->allAuth($frm3,'list_project');?><?=$this->zetro_auth->allAuth($list,'list_project');?></div></div>
       </div>
		<input type='hidden' id='row_aktif' value='<?=empty($_GET['p'])?'':$_GET['p'];?>'/>
		<input type='hidden' id='rows' value='<?=base64_decode($this->session->userdata('menus'));?>'/>
    </div>
<!--</div>-->
<?=$modal;?>
<script language='javascript'>
$(document).ready(function(e) {
	$('#frm1').validationEngine();
	$('div.tab-content').css('height',(screen.availHeight-275));
	$('a#p-table1').live('click',function(){$('#tgl_trans').removeAttr('readonly');tglNow('#tgl_trans');$('#frm1 input select').val('');$('#myModal').modal('show');});
	$('#d_Simpan').live('click',function(){$('#frm1:reset').click();$('#myModal').modal('hide');$('a#p-table2').click()});
	$('#b_Simpan').live('click',function(){($('#frm1').validationEngine('validate'))?_simpan_data():'';});
	$('.close').click(function(){ $('#d_Simpan').click();})
	$('#id_cust').html("<?=$lok;?>");
	$('#id_customer').html("<?=$lok;?>");
	$('#id_lokasi').html("<?=$lok2;?>");
	$('#tgl_trans').removeAttr('readonly');
	$('#tgl_trans').datepicker();
	$('#tgl_trans').datepicker("option","dateFormat","dd/mm/yy");
	tglNow('#tgl_trans');
	$('#start_project').datepicker();
	$('#start_project').datepicker("option","dateFormat","dd/mm/yy");
	$('#end_project').datepicker();
	$('#end_project').datepicker("option","dateFormat","dd/mm/yy");
	formatAngka('val_project');
	_show_data('')
	$('#id_cust').click(function(){ _show_data('1');})
	$('#c_cari').click(function(){ _show_data('1');})
});

function _show_data(tp)
{
	show_indicator('NewList',6);
	$.post('getprojectlist',$('#frm2').serialize(),function(result)
	{
		$('#NewList tbody').html(result);
		(tp=='')?
		$('#NewList').fixedHeader({'width':(screen.availWidth-50),'height':(screen.availHeight-320)}):'';
	})
}
function _simpan_data()
{
	$.post('setproject',$('#frm1').serialize(),function(result)
	{
		$('#result').html(result).show().fadeOut(3000);
		_show_data('1');
		$('#d_Simpan').click();
	})
}
function btn_click(id,aksi)
{
	switch(aksi)
	{
		case 'update':
			_show_detail(id);
		break;
		case 'deleted':
		jConfirm('Yakin data ini akan di hapus?','Ziebar Confirm',function(r)
		{
			if(r)
			{
				$.post('deleteproject',{'id':id},function(result)
				{
					_show_data('1');
				})
			}
		})
		break;	
	}
}

function _show_detail(id)
{
	$.post('getdetailproject',{'id':id},
	function(result)
	{
		var r=$.parseJSON(result);
		$('#tgl_trans').val(tglFromSql(r.tgl_project)).attr('readonly','readonly');
		$('#id_customer').val(r.id_customer).select();
		$('#id_lokasi').val(r.id_lokasi2).select();
		$('#nm_project').val(r.nm_project);
		$('#start_project').val(tglFromSql(r.start_project));
		$('#end_project').val(tglFromSql(r.end_project));
		$('#val_project').val(r.val_project).priceFormat();
		$('#stat_project').val(r.stat_project).select();
		$('#id_project').val(r.id_project);
		$('h4#myModalLabel').html("<i class='cus-cog'></i> Update Project ");
		$('#myModal').modal('show');	
	})
}
</script>